package com.slt.concurrency.mashibing2019.juc.c_000_Thread;

/**
 * 创建线程几种方法：
 *   继承Thread类
 *   实现Runnabale
 *   jdk8以后 lambda表达式
 */
public class T02_HowToCreateThread {
    static void m(){
        System.out.println("hello shalongteng");
    }
    static class MyThread extends Thread {
        @Override
        public void run() {
            System.out.println("Hello MyThread!");
        }
    }

    static class MyRun implements Runnable {
        @Override
        public void run() {
            System.out.println("Hello MyRun!");
        }
    }

    public static void main(String[] args) {
        //第一种 基础Thread类
        new MyThread().start();
        //第二种 runnable
        new Thread(new MyRun()).start();
        //第三种 lambda
        new Thread(()->{
            System.out.println("Hello Lambda!");
        }).start();
        //第四种 方法引用
        new Thread(T02_HowToCreateThread::m).start();

        System.out.println(Thread.currentThread().getThreadGroup());
    }

}

